/**
 * This file was created by Julia Deeb for use in SpaceTrader
 */
import java.io.Serializable;
import java.util.Random;

/**
 * This class creates the development for each of the planets
 * 
 * @author Julia Deeb
 * @version 1.0
 * 
 */
public class Development implements Serializable {
    /**
     * This array represents all possible TYPEs of development a planet can have
     */
    private final String[] type = { "Pre-Agriculture", "Agriculture", "Medieval",
	    "Renaissance", "Early Industrial", "Industrial", "Post-Industrial",
	    "Hi-Tech" };
    
    /**
     * This array represents all possible condition TYPEs a planet can have
     */
    private final String[] condition = { "NOSPECIALRESOURCES", "MINERALRICH",
	    "MINERALPOOR", "DESERT", "LOTSOFWATER", "RICHSOIL", "POORSOIL",
	    "RICHFAUNA", "LIFELESS", "WEIRDMUSHROOMS", "LOTSOFHERBS",
	    "ARTISTIC", "WARLIKE" };

    /**
     * This represents the literal development level of the planet
     */
    private final int level;

    /**
     * This represents the index of the condition that the planet will have
     */
    private int res = 0;

    /**
     * This constructor sets up the index as a random value
     */
    public Development() {
	final Random rand = new Random();
	this.level = rand.nextInt(this.type.length);
	final int chance = rand.nextInt(10); // $codepro.audit.disable numericLiterals
	final int probability = 4; // $codepro.audit.disable numericLiterals
	if (chance >= probability) {
	    this.res = rand.nextInt(condition.length);
	}
    }

    /**
     * This method returns a string representing the type of development
     * 
     * @return a string representing the type of development
     */
    public String getType() {
	return this.type[this.level];
    }

    /**
     * This method returns an integer representing a tech level of the planet
     * 
     * @return an integer representing the tech level of the planet
     */
    public int getTechLevel() {
	return this.level;
    }

    /**
     * This method return a string of the condition of the planet
     * 
     * @return a string represnting the condition of the planet
     */
    public String getCondition() {
	return this.condition[this.res];
    }

    /**
     * This method returns a string representing the name of the Development
     * type
     * 
     * @return a String representing the type of development
     */
    @Override
    public String toString() {
	return getType();
    }
}
